const Service = require("egg").Service;

class UserServce extends Service {
    async findByUsername(username) {
        let sql = "select * from user where username = ?";
        let params = [username];
        let res = await this.app.mysql.query(sql, params);
        return res[0];
    }

    async save({ username, password, nickname }) {
        let sql =
            "insert into user (username, password, nickname) values (?, ?, ?)";
        let params = [username, password, nickname];
        let res = await this.app.mysql.query(sql, params);
        return res;
    }
}

module.exports = UserServce;
